﻿
// MainFrm.cpp: CMainFrame 类的实现
//

#include "pch.h"
#include "framework.h"
#include "MFCGC.h"

#include "MainFrm.h"
#include "DIALOG2_2.h"
#include "dialog2_3.h"
#include "d2_4.h"
#include "DIALOG2_5.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	ON_WM_CREATE()
//	ON_COMMAND(ID_22, &CMainFrame::On22)
ON_COMMAND(ID_22, &CMainFrame::On22)
ON_COMMAND(ID_32778, &CMainFrame::On32778)
ON_COMMAND(ID_32779, &CMainFrame::On32779)
ON_COMMAND(ID_32780, &CMainFrame::On32780)
ON_COMMAND(ID_32781, &CMainFrame::On32781)
ON_COMMAND(ID_32782, &CMainFrame::On32782)
ON_COMMAND(ID_32785, &CMainFrame::On32785)
ON_COMMAND(ID_32786, &CMainFrame::On32786)
ON_COMMAND(ID_32788, &CMainFrame::On32788)
ON_COMMAND(ID_32789, &CMainFrame::On32789)
ON_COMMAND(ID_32790, &CMainFrame::On32790)
ON_COMMAND(ID_32791, &CMainFrame::On32791)
ON_COMMAND(ID_5_32793, &CMainFrame::On532793)
ON_COMMAND(ID_5_32794, &CMainFrame::On532794)
ON_COMMAND(ID_32792, &CMainFrame::On32792)
ON_COMMAND(ID_32795, &CMainFrame::On32795)
ON_COMMAND(ID_32796, &CMainFrame::On32796)
ON_COMMAND(ID_32797, &CMainFrame::On32797)
ON_COMMAND(ID_32798, &CMainFrame::On32798)
ON_COMMAND(ID_Menu, &CMainFrame::OnMenu)
ON_COMMAND(ID_32801, &CMainFrame::On32801)
ON_COMMAND(ID_32802, &CMainFrame::On32802)
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // 状态行指示器
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

// CMainFrame 构造/析构

CMainFrame::CMainFrame() noexcept
{
	// TODO: 在此添加成员初始化代码
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("未能创建工具栏\n");
		return -1;      // 未能创建
	}

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("未能创建状态栏\n");
		return -1;      // 未能创建
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

	// TODO: 如果不需要可停靠工具栏，则删除这三行
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);


	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: 在此处通过修改
	//  CREATESTRUCT cs 来修改窗口类或样式

	return TRUE;
}

// CMainFrame 诊断

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}
#endif //_DEBUG


// CMainFrame 消息处理程序






void CMainFrame::On22()
{
	// TODO: 2-2
	DIALOG2_2 dlg;
	dlg.DoModal();
} 


void CMainFrame::On32778()
{
	// TODO: 2-3
	dialog2_3 dlg;
	dlg.DoModal();
}


void CMainFrame::On32779()
{
	// TODO: 2.4
	nowDraw = 24;
	d2_4 dlg;
	dlg.DoModal();
	//Invalidate();
}


void CMainFrame::On32780()
{
	// TODO: 在此添加命令处理程序代码
	DIALOG2_5 dlg;
	dlg.DoModal();
}


void CMainFrame::On32781()
{
	// TODO: 展示习题3-3的绘画逻辑
	 // 获取指向主窗口的指针
	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();

	if (pMainFrame) // 确保指针有效
	{
		// 修改 CMainFrame 中的 nowDraw 变量
		pMainFrame->nowDraw = 33;
		pMainFrame->Invalidate();

	}


}

#include "DIALOG3_5.h"
void CMainFrame::On32782()
{	// TODO: 弹出3-5
	DIALOG3_5 dlg;
	dlg.DoModal();


}



#include "DIALOG3_8.h"
void CMainFrame::On32785()
{
	// TODO: 弹出3-8
	DIALOG3_8 dlg;
	dlg.DoModal();
}

#include "DIALOG3_9.h"
void CMainFrame::On32786()
{
	// TODO: 弹出3-9
	DIALOG3_9 dlg;
	dlg.DoModal();
}


void CMainFrame::On32788()
{
	// TODO: 绘制4-3 
	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();

	if (pMainFrame) // 确保指针有效
	{
		// 修改 CMainFrame 中的 nowDraw 变量
		pMainFrame->nowDraw = 43;
		pMainFrame->Invalidate();

	}
}


void CMainFrame::On32789()
{
	// TODO: 绘制4-7
	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();

	if (pMainFrame) // 确保指针有效
	{
		// 修改 CMainFrame 中的 nowDraw 变量
		pMainFrame->nowDraw = 47;
		pMainFrame->Invalidate();

	}
}


void CMainFrame::On32790()
{
	// TODO: 绘制4-9
	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();

	if (pMainFrame) // 确保指针有效
	{
		// 修改 CMainFrame 中的 nowDraw 变量
		pMainFrame->nowDraw = 49;
		pMainFrame->Invalidate();

	}
}


void CMainFrame::On32791()
{
	

}


void CMainFrame::On532793()
{
	// TODO: 绘制5-3静止
	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();

	if (pMainFrame) // 确保指针有效
	{
		// 修改 CMainFrame 中的 nowDraw 与旋转变量
		pMainFrame->rolate5_3 = 0;
		pMainFrame->nowDraw = 53;
		pMainFrame->Invalidate();

	}
}


void CMainFrame::On532794()
{
	// TODO: 绘制5-3运动
	this->rolate5_3 = 1;
	this->nowDraw = 53;
	this->Invalidate();

}

#include "Dialog5_6.h"
void CMainFrame::On32792()
{
	// TODO: 弹出5-6参数对话框
	Dialog5_6 dlg;
	dlg.DoModal();
}


void CMainFrame::On32795()
{
	// TODO: 绘制6-3
	this->nowDraw = 63;
	this->Invalidate();
}


void CMainFrame::On32796()
{
	// TODO: 绘制6-4
	this->nowDraw = 64;
	this->Invalidate();
}


void CMainFrame::On32797()
{
	// TODO: 绘制8-3
	this->nowDraw = 83;
	this->Invalidate();
}


void CMainFrame::On32798()
{
	// TODO:绘制8-5
	this->nowDraw = 85;
	this->Invalidate();
}


void CMainFrame::OnMenu()
{
	// TODO:绘制7-1
	this->nowDraw = 71;
	this->Invalidate();
}


void CMainFrame::On32801()
{
	// TODO:绘制7-2
	this->nowDraw = 72;
	this->Invalidate();
}


void CMainFrame::On32802()
{
	// TODO:绘制9-70
	this->nowDraw = 73;
	this->Invalidate();
}
